﻿using CnSharp.SSMS.AddIn.Util;
using Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer;

namespace CnSharp.SSMS.AddIn.Framework
{
    public static class ObjectContextMenuGroupHelper
    {
        public static ObjectContextMenuGroup JudgeMenuGroup(INodeInformation node)
        {
            var group = ObjectContextMenuGroup.Other;

            if (ObjectNodeContextRegex.TableRegex.IsMatch(node.Context))
                @group = ObjectContextMenuGroup.Table;
            else if (ObjectNodeContextRegex.ViewRegex.IsMatch(node.Context))
                @group = ObjectContextMenuGroup.View;
            else if (ObjectNodeContextRegex.SpRegex.IsMatch(node.Context))
                @group = ObjectContextMenuGroup.Procedure;
            else if (ObjectNodeContextRegex.TableFolderRegex.IsMatch(node.Context))
                @group = ObjectContextMenuGroup.TableFolder;
            else if (ObjectNodeContextRegex.ViewFolderRegex.IsMatch(node.Context))
                @group = ObjectContextMenuGroup.ViewFolder;
            else if (ObjectNodeContextRegex.SpFolderRegex.IsMatch(node.Context))
                @group = ObjectContextMenuGroup.ProcedureFolder;
            else if (ObjectNodeContextRegex.DbRegex.IsMatch(node.Context))
                @group = ObjectContextMenuGroup.Database;
            return @group;
        }

    }
}